// pages/user/visitrecord/visitrecord.js
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        norecord: false,
        hiddenModal: true,
        applyVisitList:[],
        applyObject:[],
        noticeList:[],
    },
    listenerButton() {
        this.setData({
            hiddenModal: !this.data.hiddenModal
        })
    },
    listenerConfirm() {
        this.setData({
            hiddenModal: true
        })
    },
    listenerCancel() {
        this.setData({
            hiddenModal: true
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        this.getAllList();
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    // 分享
    onShareAppMessage(res) {
        return {
            title: '广州大学校友会校友企业家专委会',
            path: '/pages/index/index'
        }
    },
    getAllList:function(){
        let _this = this;
        app.util.ajax({
            url: 'user/info',
            data: {
                user_id: app.globalData.userInfo.user_id
            },
            success:function(res){
                _this.setData({
                    applyVisitList:res.info,
                    applyObject:res.infos,
                    noticeList:res.infoss
                })
            }
        })
    },
    // 同意申请
    submitArgee:function(e){
        console.log(e,'123123')
        let id = e.detail.target.dataset.id,
            formId = e.detail.formId,
            _this = this;

        app.util.ajax({
            url:'user/info',
            data:{
                user_id:app.globalData.userInfo.user_id,
                member_id:id,
                state:1,
                form_id:formId
            },
            success:function(res){
                wx.showToast({
                    title:'已同意'
                });
                _this.getAllList();
            }
        })
    },
    // 拒绝申请
    submitRefuse:function(e){
        let id = e.detail.target.dataset.id,
            formId = e.detail.formId,
            _this = this;
        app.util.ajax({
            url:'user/info',
            data:{
                user_id:app.globalData.userInfo.user_id,
                member_id:id,
                state:2,
                form_id:formId
            },
            success:function(res){
                wx.showToast({
                    title:'已拒绝'
                });
                _this.getAllList();
            }
        })
    },
    // 查看名片
    getCardMsg:function(e){
        let cardType = Number(e.currentTarget.dataset.type),
            id = e.currentTarget.dataset.id,
            userType = e.currentTarget.dataset.usertype,
            requestObj = {},
            requestArr = ['member_id','user_id','userid'],
            idType = requestArr[cardType],
            _this = this;
        requestObj[idType] = id;
        app.util.ajax({
            url:'user/business',
            data:requestObj,
            success:function(res){
                wx.navigateTo({
                    url: '/pages/user/personal/personal?id='+id+'&state='+userType
                })
            }
        })
    }
})